<?php
/**
 * Core_View_Title
 * 
 * @author naspeh
 * @version $Id: Title.php 659 2008-06-15 11:34:26Z naspeh $
 */
class Core_View_Title
{
    /**
     * Базовый заголовок
     *
     */
    const TITLE_BASE = 'Links2';
    /**
     * Разделитель в заголовке
     *
     */
    const TITLE_SEPARATOR = ' | ';    
    protected static $_data = array();
    public static function add($title)
    {
        self::$_data[] = (string) $title;
    }
    public static function addByUrl()
    {
        $actionsTable = new Core_Table_Actions();
        $request = Core_Controller_Front::getInstance()->getRequest();
        $url = implode('/', array($request->getModuleName(), $request->getControllerName(), $request->getActionName()));
        $action = $actionsTable->fetchByUrl($url);
        if (null !== $action) {
            self::add($action['desc']);
        }
    }
    public static function clear()
    {
        self::$_data = array();
    }
    public static function get()
    {
        $result = implode(self::TITLE_SEPARATOR, self::$_data);
        $result = implode(self::TITLE_SEPARATOR, array(self::TITLE_BASE, $result));
        return $result;
    }
    public static function set($title)
    {
        self::clear();
        self::add($title);
    }
    public static function setByUrl()
    {
        self::clear();
        self::addByUrl();
    }
}
